package zozopo.user;

import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.sql.SQLException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.SessionAware;

import zozopo.user.operations.UserOS;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class ActiveUserAction  extends ActionSupport implements Action ,SessionAware{
	
	
	public String execute(){
		ActionContext actionContext = ActionContext.getContext(); 
		HttpServletRequest request = (HttpServletRequest)actionContext.get(ServletActionContext.HTTP_REQUEST); 
		
		String activeCode = request.getParameter("active");
		int externalid  = Integer.parseInt(request.getParameter("externalid"));
		String key         = request.getParameter("key");
		
		String forward = "error";
		
		UserOS userOS = new UserOS();
		//UserTB user = new UserTB();
		
		if(userOS.activeUser(activeCode, key,externalid)){
			forward = "success";
			ActionContext.getContext().getSession().clear();
		}else{
			forward = "error";
		}
		
		return forward;
	}

	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
	}
}
